#include <stdio.h>

//进制转换 
//NUM一直用D除下去,然后保存余数，最后倒着输出余数

int main()
{
	char output[1000] = {0};
	int A = 0, B = 0, D = 0;
	scanf("%d %d %d", &A, &B, &D);
	int num = A + B;
	int i = 0;
	while(num != 0){
		output[i++] = num % D;
		num = (num - (num % D)) / D;
	}
	//倒着输出余数
	for(i--; i >= 0;i--){
		printf("%d", output[i]);
	}
	printf("\n");
	return 0;
}
